<?php

session_start();

if(isset($_POST['sm1'])){
	include '../source/class/class_core.php';
	
	$user_name = trim($_POST['user_name']);
	$pwd = md5(trim($_POST['pwd']));
	
	if(DB::fetch_first("SELECT * FROM `om_admin_user` WHERE name = '$user_name' AND pwd = '$pwd'")){
		$_SESSION['admin_login'] = true;
		$_SESSION['user_name'] = $user_name;
		echo "<script>window.location.href='index.php';</script>";
	} else {
		echo "<script>alert('提示：该用户不存在！');</script>";
	}
}

if(isset($_REQUEST['logout'])){
	session_destroy();
	echo "<script>alert('提示：安全退出！');</script>";
}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<link href="css/base.css" rel="stylesheet" type="text/css" />
<link href="css/login.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="login-box">
   <div class="login-top"></div>
   <div class="login-main">
    <form name="form1" method="post" action="login.php">
      <dl>
	   <dt>用户名：</dt>
	   <dd><input type="text" name="user_name"/></dd>
	   <dt>密&nbsp;&nbsp;码：</dt>
	   <dd><input type="password" class="alltxt" name="pwd"/></dd>
		<dt>&nbsp;</dt>
		<dd><button type="submit" name="sm1" class="login-btn">登录</button></dd>
		<dd><button type="submit" name="logout" class="login-btn">退出</button></dd>
	 </dl>
	</form>
   </div>
   <div class="login-power">Mutongfan</div>
</div>
</body>
</html>
